package lore.miniwechat.dto;

public class BaseResponse {
    private String code;
    private String message;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("BaseResponse{");
        sb.append("code='").append(code).append('\'');
        sb.append(", message='").append(message).append('\'');
        sb.append('}');
        return sb.toString();
    }

    /**
     * 创建全局成功消息
     *
     * @return
     */
    public static BaseResponse success() {
        BaseResponse response = new BaseResponse();
        response.setCode("0");
        response.setMessage("success");

        return response;
    }

    /**
     * 创建错误消息
     *
     * @return
     */
    public static BaseResponse error(String code, String message) {
        BaseResponse response = new BaseResponse();
        response.setCode(code);
        response.setMessage(message);

        return response;
    }
}
